<template>
	<view class="returnOrder">
		
		<view style="padding-top:50rpx" v-if="orderList.length==0">
			数据为空
		</view>
		
		<template v-else>
			<view class="order-holder" v-for="item in orderList" :key="item.id">
				<view class="order-info" @tap="toReturnInfo(item.id)">
					<text>订单编号{{item.orderId}}</text>
					<text v-if="item.status==0">等待处理</text>
					<text v-if="item.status==1">确认退货,等待发货</text>
					<text class="red" v-if="item.status==2">已退款</text>
					<text class="red" v-if="item.status==3">已拒绝</text>
					<text v-if="item.status==9">拒绝退货</text>
				</view>
				<view class="list">
					<view class="item">
						<image class="img" :src="item.productPic" mode=""></image>
			
						<view class="right">
							<view class="name">
								<text>{{item.productName}}</text>
								<text>￥{{item.productPrice}}</text>
							</view>
			
							<view class="count">
								<text>编号：{{item.productSkuId}}</text>
								<text>x{{item.productCount}}</text>
							</view>
			
							<view class="type">
								<text>规格：</text>
								<text v-for="item1 in JSON.parse(item.productAttr)">{{item1.key}}:{{item1.value}} </text>
							</view>
						</view>
					</view>
				</view>
			
				<view class="sum-price">
					<view class="sum">
						<text>时间：{{item.createTime}}</text>
						<text>合计：￥{{item.returnAmount}}元</text>
					</view>
				</view>
			</view>
		</template>
	</view>
</template>

<script>
	import {
		requestGetReturnList
	} from 'api/user/order.js';
	export default {
		data() {
			return {
				orderList:[],
			};
		},
		methods:{
			toReturnInfo(id){
				uni.navigateTo({
					url:`/pages/user/order/return-goods-info/return-goods-info?id=${id}`
				})
			}
		},
		created() {
			requestGetReturnList().then(res=>{
				console.log(res);
				this.orderList = res.data.items;
			})
		}
	}
</script>

<style lang="scss" scoped>
	.returnOrder {
		box-sizing: border-box;
		padding: 40rpx;
		width: 100%;

		.order-holder {
			box-sizing: border-box;
			margin: 30rpx 0;
			padding: 36rpx;
			border-radius: 24rpx;
			background-color: #fff;
			overflow: hidden;

			.order-info {
				display: flex;
				padding-bottom: 20rpx;
				justify-content: space-between;
				font-size: 24rpx;
				border-bottom: 1px solid #f1ece7;
				
				.red{
					color: #f00;
				}
			}

			.list {
				.item {
					box-sizing: border-box;
					padding: 30rpx 0;
					display: flex;
					align-items: center;
					width: 100%;
					border-bottom: 1px solid #f1ece7;

					.img {
						width: 162rpx;
						height: 162rpx;
					}

					.right {
						margin-left: 30rpx;
						flex: 1;

						.name {
							font-size: 13px;
							line-height: 37px;
							display: flex;
							justify-content: space-between;
						}

						.count {
							display: flex;
							justify-content: space-between;
							font-size: 22rpx;
							color: #8d8d8d;
							line-height: 30rpx;
							margin-top: 4rpx;
						}
					}
				}
			}

			.sum-price {
				float: right;
				width: 100%;
				margin-top: 20rpx;

				.sum {
					display: flex;
					justify-content: space-between;
				}

				.submit-btn {
					margin-left: 32rpx;
					margin-top: 20rpx;
					float: right;
					width: 124rpx;
					height: 50rpx;
					font-size: 26rpx;
					border: 2rpx solid #2d4f43;
					text-align: center;
					color: #2d4f43;
					border-radius: 10rpx;
					line-height: 50rpx;
				}
			}
		}
	}
</style>


